/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "sle_announce_impl.h"
#include "cmd_input.h"
#include <vector>
#include <memory>
#include <cstring>
#include <iterator>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <sys/socket.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <memory>
#include <functional>

namespace OHOS {
namespace NearLink {
namespace SleStandard {
namespace {
using namespace testing::ext;
static SleAnnounce g_announceInstance;

} // namespace

class AnnounceHandlerTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp();
    void TearDown();

    static uint8_t g_announceId;
    static uint8_t announceData[12];
    static uint8_t responseData[12];

    };

    // 静态成员初始化
uint8_t AnnounceHandlerTest::g_announceId = 1; // 这里设置一个固定的 ID，根据实际需求调整
uint8_t AnnounceHandlerTest::announceData[12] = {'k', 'h', '_', 's', 'l', 'e', '_', 't', 'o', 'o', 'l', ':'};
uint8_t AnnounceHandlerTest::responseData[12] = {'k', 'h', '_', 's', 'l', 'e', '_', 't', 'o', 'o', 'l', ':'};

void AnnounceHandlerTest::SetUpTestCase() {}

void AnnounceHandlerTest::TearDownTestCase() {}

void AnnounceHandlerTest::SetUp() {}

void AnnounceHandlerTest::TearDown() {}

HWTEST_F(AnnounceHandlerTest, AddAnnounceTest, TestSize.Level1)
{
    SleErrorCode ret = g_announceInstance.AddAnnounce(g_announceId);
    EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(AnnounceHandlerTest, RemoveAnnounceTest, TestSize.Level1)
{
    SleErrorCode ret = g_announceInstance.RemoveAnnounce(g_announceId);
    EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(AnnounceHandlerTest, StartAnnounceTest, TestSize.Level1)
{
    // 直接使用静态的固定参数数据
    SleAnnounceData data = {
        .announceLength = static_cast<uint16_t>(std::size(announceData)),
        .announceData = announceData,
        .responceLength = static_cast<uint16_t>(std::size(responseData)),
        .responceData = responseData,
    };
    SleAnnounceParam setting;
    
    SleErrorCode ret = g_announceInstance.StartAnnounce(g_announceId, data, setting);
    EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED); // 使用 SLE_ERR_INTERNAL_WRONG 根据实际情况调整
}

HWTEST_F(AnnounceHandlerTest, StopAnnounceTest, TestSize.Level1)
{
    SleErrorCode ret = g_announceInstance.StopAnnounce(g_announceId);
    EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
}
}
} // namespace NetManagerStandard
} // namespace OHOS